using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace DSEngine.Core
{
    public class ResourceManager
    {
        Game game;
        ContentManager manager;
        public ResourceManager(Game g)
        {
            game = g;
            manager = new ContentManager(game.Services);
            manager.RootDirectory = "Content";
        }
        Dictionary<string, object> dict = new Dictionary<string, object>();
        public T Load<T>(string name)
        {
            if (dict.ContainsKey(name))
            {
                return (T)dict[name];
            }
            else
            {
                T t = manager.Load<T>(name);
                dict.Add(name, t);
                return t;
            }
        }
        public void Unload()
        {
            dict.Clear();
            manager.Unload();
            manager.Dispose();
        }
    }
}
